package com.srv.servlet;

import java.io.IOException;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.srv.dao.DAOVeiculo;
import com.srv.pojo.Veiculo;

/**
 * Servlet implementation class CadastraVeiculoServlet
 */
@WebServlet("/CadastraVeiculoServlet")
public class CadastraVeiculoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CadastraVeiculoServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		Veiculo veiculo = new Veiculo();
		veiculo.setTipoVeiculo(Integer.parseInt(request.getParameter("tpVeiculo")));
		veiculo.setDescricao(request.getParameter("descVeiculo"));
		veiculo.setQtdFilas(Integer.parseInt(request.getParameter("qtdFilas")));
		veiculo.setQtdPoltronas(Integer.parseInt(request.getParameter("qtdPoltronasFila")));
		DAOVeiculo dao;
		try {
			dao = new DAOVeiculo();
			dao.adicionarVeiculo(veiculo);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
			e.printStackTrace();	
		}	
	}
}
